home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / P Examples / nshc.p < prev    next >
Encoding:
Text File  |  1994-08-28  |  3.0 KB  |  115 lines  |  [TEXT/PJMM]

  1. unit NSHC;
  2.  
  3. {  ================================================== }
  4.  
  5. { nshc.p - a pascal interface for nShell (tm) commands. }
  6.  
  7. { Copyright ( c ) 1994 Newport Software Development }
  8.  
  9. { You may distribute unmodified copies of this file for noncommercial }
  10. { purposes . You may use this file as a reference when writing your }
  11. { own nShell ( tm ) commands . }
  12.  
  13. { All other rights are reserved . }
  14.  
  15. {  ================================================== }
  16.  
  17. interface
  18.  
  19. {  ================================================== }
  20.  
  21.     const
  22.  
  23.     { The version of this file. }
  24.  
  25.         NSHC_VERSION = 10;
  26.  
  27.     { common error definitions }
  28.  
  29.         NSHC_NO_ERR = 0;
  30.         NSHC_ERR_GENERAL = -1;
  31.         NSHC_ERR_VERSION = -2;
  32.         NSHC_ERR_PARMS = -3;
  33.         NSHC_ERR_MEMORY = -4;
  34.         NSHC_ERR_FILE = -5;
  35.  
  36.     { limits to data structures }
  37.  
  38.         MAX_ARGS = 100;
  39.         LINE_MAX = 2048;
  40.  
  41.         ARG_ARRAY = MAX_ARGS - 1;
  42.         LINE_ARRAY = LINE_MAX - 1;
  43.  
  44.     { misc. }
  45.  
  46.         RETURN_CHAR = CHR(13);
  47.  
  48.     type
  49.  
  50.     { these states define command action }
  51.  
  52.         t_nsh_state = (nsh_idle, nsh_start, nsh_continue, nsh_stop);
  53.  
  54.     { this parameter block defines data passed: application <--> command }
  55.  
  56.         t_nshc_rec = record
  57.                 version: integer;
  58.                 action: t_nsh_state;
  59.                 result: integer;
  60.                 argc: integer;
  61.                 argv: array[0..ARG_ARRAY] of integer;
  62.                 arg_buf: packed array[0..LINE_ARRAY] of char;
  63.                 data: Handle;
  64.             end;
  65.  
  66.     { misc. types }
  67.  
  68.         t_nshc_parms = ^t_nshc_rec;
  69.         t_nshc_calls = Ptr;
  70.  
  71. {  ================================================== }
  72.  
  73. { Interfaces to nShell callback routines. }
  74.  
  75. {  output to stderr }
  76.  
  77.     procedure NSH_putchar_err (nshc_calls: t_nshc_calls; c: char);
  78.     procedure NSH_puts_err (nshc_calls: t_nshc_calls; c_string: ptr);
  79.     procedure NSH_putStr_err (nshc_calls: t_nshc_calls; s: Str255);
  80.  
  81. {  output to stdout }
  82.  
  83.     procedure NSH_putchar (nshc_calls: t_nshc_calls; c: char);
  84.     procedure NSH_puts (nshc_calls: t_nshc_calls; c_string: ptr);
  85.     procedure NSH_putStr (nshc_calls: t_nshc_calls; s: Str255);
  86.  
  87. { input from stdin }
  88.  
  89.     function NSH_getchar (nshc_calls: t_nshc_calls): integer;
  90.     function NSH_gets (nshc_calls: t_nshc_calls; c_string: ptr; size: integer): integer;
  91.     function NSH_getStr (nshc_calls: t_nshc_calls; s: Str255): integer;
  92.  
  93. { variable access functions }
  94.  
  95.     function NSH_var_set (nshc_calls: t_nshc_calls; name: Str32; value: Str255): integer;
  96.     function NSH_var_unset (nshc_calls: t_nshc_calls; name: Str32): integer;
  97.     function NSH_var_env (nshc_calls: t_nshc_calls; name: Str32; value: Str255): integer;
  98.  
  99. { path expansion functions }
  100.  
  101.     function NSH_path_expand (nshc_calls: t_nshc_calls; path: Str255): integer;
  102.     function NSH_path_to_FSSpec (nshc_calls: t_nshc_calls; pathname: Str255; spec: FSSpecPtr): integer;
  103.     function NSH_path_which (nshc_calls: t_nshc_calls; path: Str255): integer;
  104.  
  105. { dialog functions }
  106.  
  107.     procedure NSH_notify (nshc_calls: t_nshc_calls; s: Str255; size: integer);
  108.     function NSH_ask (nshc_calls: t_nshc_calls; s: Str255; size: integer): integer;
  109.  
  110. { misc }
  111.  
  112.     function NSH_match (nshc_calls: t_nshc_calls; pattern: Str255; target: Str255): integer;
  113.  
  114. implementation
  115. end.